package com.tony.jrp.config;


import lombok.Data;

import java.util.List;
import java.util.Objects;

/**
 * 反向代理配置
 */
@Data
public class JRPProxy {
    /**
     * 代理服务名称
     */
    private String name;
    /**
     * 代理类型
     */
    private ProxyType type;
    /**
     * 证书文件
     */
    private String cert_cer;
    /**
     * 私钥文件
     */
    private String cert_key;
    /**
     * 代理后端口
     */
    private Integer listen;
    /**
     * TCP等类型的被代理地址，格式：host:port，127.0.0.1:8080
     */
    private String proxy_pass;
    /**
     * HTTP,HTTPS,FILE代理路径配置
     */
    private List<JRPLocation> locations;

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;
        JRPProxy proxy = (JRPProxy) o;
        return Objects.equals(proxy.key(), this.key());
    }

    @Override
    public int hashCode() {
        return Objects.hash(this.type, this.cert_cer, this.cert_key, this.listen, this.proxy_pass);
    }

    public String key() {
        return "JRPProxy{" +
                ", type=" + type +
                ", cert_cer='" + cert_cer + '\'' +
                ", cert_key='" + cert_key + '\'' +
                ", listen=" + listen +
                ", proxy_pass='" + proxy_pass + '\'' +
                '}';
    }
}
